library(here)
library(galah)
library(skimr)
library(dplyr)
library(lubridate)
library(tidyr)
library(stringr)
library(ggplot2)
library(leaflet)
library(leaflet.extras)
library(reactable)
library(scico)
library(hrbrthemes)
reptilia <- readRDS(here("data", "reptilia"))

reptilia_tidy <- reptilia %>% 
  filter(cl22 == "Australian Capital Territory") %>% 
  rename(state = cl22, 
         forestType = cl10902) %>% 
  mutate(forestType = na_if(forestType, ""),
         family = na_if(family, ""),
         basisOfRecord = tolower(basisOfRecord),
         basisOfRecord = str_replace(basisOfRecord, "_", " "),
         eventDate = as_datetime(eventDate, tz = "Australia/Sydney", format = NULL),
         eventDate = as_date(eventDate, tz = NULL),
         month = month(eventDate))

Exploratory data analysis

Summary statistics

Summary statistics for fields in the dataset of reptile occurrences in the ACT

skim(reptilia_tidy)
Data summary
Name reptilia_tidy
Number of rows 10145
Number of columns 12
_______________________
Column type frequency:
character 8
Date 1
numeric 3
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
scientificName 0 1 4 33 0 102 0
genus 0 1 0 16 106 52 0
family 38 1 8 15 0 11 0
order 0 1 0 10 4 3 0
dataResourceName 0 1 9 87 0 23 0
basisOfRecord 0 1 7 18 0 5 0
state 0 1 28 28 0 1 0
forestType 17 1 6 31 0 10 0

Variable type: Date

skim_variable n_missing complete_rate min max median n_unique
eventDate 5206 0.49 1954-01-22 2021-11-25 2012-10-08 1783

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
decimalLatitude 0 1.00 -35.34 0.15 -35.91 -35.40 -35.3 -35.24 -35.12 ▁▁▃▇▇
decimalLongitude 0 1.00 149.11 0.30 148.76 148.99 149.1 149.15 150.77 ▇▂▁▁▁
month 5206 0.49 7.92 3.92 1.00 3.00 10.0 11.00 12.00 ▃▁▁▂▇

Occurrence map

Locations of reptiles in the ACT based on occurrence records of reptiles from the ALA. Interactive layers in the top right corner allow records to be differentiated based on the type of record (ALA id: basisOfRecord), forest type (ALA id: cl10902), and taxonomic family (ALA id: family) associated with each record.

Occurrence records

Occurrence records for reptiles in the ACT. Columns may be sorted by clicking on column names, or filtered using the search bars under each column header. A global search bar in the top right corner enables searching the whole table.

# remove cols not of interest in a table
reptilia_subset <- reptilia_tidy %>% 
  select(eventDate:basisOfRecord, forestType)

reactable(
  reptilia_subset,
  columns = list(
    eventDate = colDef(name = "Date"),
    scientificName = colDef(name = "Species"),
    genus = colDef(name = "Genus"),
    family = colDef(name = "Family"),
    order = colDef(name = "Order"),
    dataResourceName = colDef(name = "Source"),
    basisOfRecord = colDef(name = "Record type"),
    forestType = colDef(name = "Forest type")
  ),
  showSortable = TRUE,
  filterable = TRUE,
  searchable = TRUE,
  striped = TRUE
)

Occurrence records over time

All records

Reptile occurrence counts between 1954 and 2021 in the ACT

reptilia_tidy %>%
  filter(!is.na(eventDate)) %>% 
  group_by(eventDate) %>%
  summarise(count = n()) %>%
  ggplot() +
  geom_line(aes(x = eventDate, y = count), 
            color = "#41507B") +
  labs(x = "",
       y = "Count") +
  theme_ipsum()

Records by family

Reptile occurrence counts by taxonomic family between 1954 and 2021 in the ACT

reptilia_tidy %>%
  filter(!is.na(eventDate)) %>% 
  group_by(eventDate) %>%
  summarise(count = n(), family = family) %>%
  ggplot() +
  geom_line(aes(x = eventDate, y = count), 
            color = "#41507B") +
  facet_wrap(~family) +
  labs(x = "Date",
       y = "") +
  theme_ipsum()

Seasonal differences in counts

Occurrence counts of individuals by family, across the different months of the year. Although the number of counts varies widely among families, the patterns across months are similar. NB counts have not been transformed to account for differences in the number of species in each family.

Citation

ALA occurrence download https://doi.org/10.26197/ala.d39e79e3-de01-4894-a5c2-babab99da04e. Accessed from R with galah 1.3.1 (https://github.com/AtlasOfLivingAustralia/galah/) on 2021-12-05.

sessionInfo()
## R version 4.1.1 (2021-08-10)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19043)
## 
## Matrix products: default
## 
## locale:
## [1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252   
## [3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
## [5] LC_TIME=English_Australia.1252    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] hrbrthemes_0.8.0     scico_1.2.0          reactable_0.2.3     
##  [4] leaflet.extras_1.0.0 leaflet_2.0.4.1      ggplot2_3.3.5       
##  [7] stringr_1.4.0        tidyr_1.1.4          lubridate_1.7.10    
## [10] dplyr_1.0.7          skimr_2.1.3          galah_1.3.1         
## [13] here_1.0.1          
## 
## loaded via a namespace (and not attached):
##  [1] httr_1.4.2              sass_0.4.0              jsonlite_1.7.2         
##  [4] bslib_0.3.1             assertthat_0.2.1        highr_0.9              
##  [7] sp_1.4-5                triebeard_0.3.0         wellknown_0.7.4        
## [10] urltools_1.7.3          yaml_2.2.1              gdtools_0.2.3          
## [13] Rttf2pt1_1.3.8          pillar_1.6.3            lattice_0.20-44        
## [16] glue_1.4.2              extrafontdb_1.0         digest_0.6.28          
## [19] leaflet.providers_1.9.0 colorspace_2.0-2        htmltools_0.5.2        
## [22] reactR_0.4.4            pkgconfig_2.0.3         httpcode_0.3.0         
## [25] purrr_0.3.4             scales_1.1.1            tibble_3.1.5           
## [28] proxy_0.4-26            farver_2.1.0            generics_0.1.0         
## [31] ellipsis_0.3.2          withr_2.4.2             repr_1.1.3             
## [34] magrittr_2.0.1          crayon_1.4.1            evaluate_0.14          
## [37] data.tree_1.0.0         fansi_0.5.0             class_7.3-19           
## [40] tools_4.1.1             data.table_1.14.2       lifecycle_1.0.1        
## [43] munsell_0.5.0           compiler_4.1.1          jquerylib_0.1.4        
## [46] e1071_1.7-9             systemfonts_1.0.2       rlang_0.4.11           
## [49] classInt_0.4-3          units_0.7-2             grid_4.1.1             
## [52] htmlwidgets_1.5.4       crosstalk_1.1.1         labeling_0.4.2         
## [55] base64enc_0.1-3         rmarkdown_2.11          wk_0.5.0               
## [58] gtable_0.3.0            DBI_1.1.1               curl_4.3.2             
## [61] R6_2.5.1                knitr_1.36              fastmap_1.1.0          
## [64] extrafont_0.17          utf8_1.2.2              rprojroot_2.0.2        
## [67] KernSmooth_2.23-20      stringi_1.7.5           crul_1.1.0             
## [70] Rcpp_1.0.7              vctrs_0.3.8             sf_1.0-4               
## [73] tidyselect_1.1.1        xfun_0.26